/* M.Angels Moncusi 2003 */
/* cc pinfo.c  -lpthread  -o pinfo */

#define _REENTRANT
#include <pthread.h>

int main()
{ int detach,sched,scope,policy;
  pthread_attr_t attr;
  struct sched_param param;

  pthread_attr_init(&attr); 
  pthread_attr_getdetachstate(&attr,&detach);
  switch (detach)
  {	 case PTHREAD_CREATE_JOINABLE: printf("PTHREAD_CREATE_JOINABLE\n"); break;
	 case PTHREAD_CREATE_DETACHED: printf("PTHREAD_CREATE_DETACHED\n"); break;
	 default: printf("cap de PTHREAD_CREATE_JOINABLE ni PTHREAD_CREATE_DETACHED\n"); break;
  }
  pthread_attr_getschedpolicy(&attr,&policy);
  switch (policy)
  {	 case SCHED_OTHER: printf("SCHED_OTHER\n"); break;
	 case SCHED_RR: printf("SCHED_RR\n"); break;
   	 case SCHED_FIFO: printf("SCHED_FIFO\n"); break;
	 default: printf("cap de SCHED_OTHER, SCHED_RR, SCHED_FIFO\n"); break;
  }
  pthread_attr_getinheritsched(&attr,&sched);
  switch (sched)
  {	 case PTHREAD_EXPLICIT_SCHED: printf("PTHREAD_EXPLICIT_SCHED\n"); break;
	 case PTHREAD_INHERIT_SCHED: printf("PTHREAD_INHERIT_SCHED\n"); break;
	 default: printf("cap de PTHREAD_EXPLICIT_SCHED,PTHREAD_INHERIT_SCHED\n"); break;
  }
  pthread_attr_getscope(&attr,&scope);
  switch (scope)
  {	 case PTHREAD_SCOPE_PROCESS: printf("PTHREAD_SCOPE_PROCESS\n"); break;
	 case PTHREAD_SCOPE_SYSTEM: printf("PTHREAD_SCOPE_SYSTEM\n"); break;
	 default: printf("cap de PTHREAD_SCOPE_PROCESS,PTHREAD_SCOPE_SYSTEM\n"); break;
  }
  pthread_attr_getschedparam(&attr,&param);
  printf("prioritat=%i\n",param.sched_priority);
  pthread_attr_destroy(&attr);
  exit(0);
}  /* main */

